package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.user.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;


@Controller
@RequestMapping("/hello")
public class HelloContrller {
    //后端的页面渲染
    @GetMapping("/h")
   // public String h(HttpServletRequest request, Model model){
    //  request.setAttribute("world","你真好");
    public String h(Model model, HttpSession session){

        model.addAttribute("world","你真好");

        List<String> list = new ArrayList<>();
        list.add("刘胖纸");
        list.add("孟胖子");
        list.add("胖子小分队");
        model.addAttribute("list",list);

        UserInfo userInfo = new UserInfo();
        userInfo.setName("小胖子");
        model.addAttribute("userInfo",userInfo);

        session.setAttribute("session110","我是session中的值");


        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");

        return "hello";
    }
}
